package czh.cocoa.foundation;

import java.util.Date;

public class NSDate extends NSObject {

	private Date mDate;
	
	public static NSDate dateWithTimeIntervalSince1970(double seconds) {
		return new NSDate(seconds);
	}
	
	public static NSDate dateWithTimeIntervalSinceNow(double seconds) { 
		double now = new NSDate().timeIntervalSince1970();
		return new NSDate(now + seconds);
	}
	
	public NSDate() {
		mDate = new Date();
	}
	
	public NSDate(double seconds) {
		mDate = new Date((long) (seconds * 1000));
	}
	
	public NSDate(Date date) {
		mDate = date;
	}
	
	public NSDate dateByAddingTimeInterval(double seconds) {
		double timestamp = timeIntervalSince1970() + seconds;
		return new NSDate(timestamp);
	}
	
	public double timeIntervalSince1970() {
		return mDate.getTime() / 1000.0;
	}
	
	public double timeIntervalSinceNow() {
		double now = new NSDate().timeIntervalSince1970();
		return timeIntervalSince1970() - now;
	}
	
	Date date() {
		return mDate;
	}
	
}
